<%--                                                                       --%>
<%-- Copyright (c) 2005-2007 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<%
  String ctxPath = request.getContextPath();
%>

<script language="JavaScript">

//
//
//
function doChannelConfirmDelete() {
  return confirm('<bean-el:message key="ep.channel.confirm.delete" bundle="ep.messages"/>');
}

//
//
//
function doChannelSetStatus(form, status) {
  form.action = "<c:url value="/ep/myChannelsSetOnlineStatus.do"/>";
  if (0 == status) {
    form.action = "<c:url value="/ep/channelSetOfflineStatus.do"/>";
  }

  form.submit();
}

//
//
//
function setChannelAction(form) {
  form.action = "<c:url value="/ep/channelSearch.do"/>";
}

//
//
//
function setProgramAction(form) {
  form.action = "<c:url value="/ep/programSearch.do"/>";
}

<%@ include file="/mc/common/jsutils.jsp" %>

</script>

<c:set var="editImg">
<img src="<%= ctxPath %>/ep/images/action/icon_edit.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean-el:message key="image.alt.edit" bundle="ep.messages"/>" title="<bean-el:message key="image.alt.edit" bundle="ep.messages"/>">
</c:set>
<c:set var="offlineImg">
<img src="<%= ctxPath %>/ep/images/action/icon_offline.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean-el:message key="image.alt.setOffline" bundle="ep.messages"/>" title="<bean-el:message key="image.alt.setOffline" bundle="ep.messages"/>">
</c:set>
<c:set var="onlineImg">
<img src="<%= ctxPath %>/ep/images/action/icon_online.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean-el:message key="image.alt.setOnline" bundle="ep.messages"/>" title="<bean-el:message key="image.alt.setOnline" bundle="ep.messages"/>">
</c:set>
<c:set var="deleteImg">
<img src="<%= ctxPath %>/ep/images/action/icon_delete.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean-el:message key="image.alt.delete" bundle="ep.messages"/>" title="<bean-el:message key="image.alt.delete" bundle="ep.messages"/>">
</c:set>

<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
  <tr>
    <td valign="top" width="100%">
      <div class="pageTitle">
      <bean-el:message key="ep.my.channels.page.title" bundle="ep.messages"/>
      </div>
      <div class="errorMessage"><html-el:errors bundle="ep.messages"/></div>
      <%@include file="/mc/common/pagetab.jsp" %>

<c:if test="${channels != null}">

      <div class="pageSubtitle">
        <span class="left"><bean-el:message key="ep.my.channels.results" arg0="${pager.map.count}" bundle="ep.messages"/></span>
        <span class="right">
        </span>
      </div>

      <form>

      <input type="hidden" name="ctx.f" value="<c:out value="${requestScope['ctx.f']}"/>"/>

<c:if test="${not empty channels}">
      <div class="globalButtonWrap">
        <input type="button" name="selectAllChannels" class="globalButton" value="<bean-el:message key="button.selectAll" bundle="ep.messages"/>"
          onclick="check(this.form.channelIds, this);">
        <input type="button" class="globalButton" value="<bean-el:message key="button.setOnline" bundle="ep.messages"/>"
          onclick="if (isAnyChecked(this.form.channelIds, '<bean-el:message key="ep.channel.atLeastOne" bundle="ep.messages"/>')) doChannelSetStatus(this.form, 1);">
        <input type="button" class="globalButton" value="<bean-el:message key="button.setOffline" bundle="ep.messages"/>"
          onclick="if (isAnyChecked(this.form.channelIds, '<bean-el:message key="ep.channel.atLeastOne" bundle="ep.messages"/>')) doChannelSetStatus(this.form, 0);">
        <input type="button" class="globalButton" value="<bean-el:message key="button.delete" bundle="ep.messages"/>"
          onclick="if (isAnyChecked(this.form.channelIds, '<bean-el:message key="ep.channel.atLeastOne" bundle="ep.messages"/>', '<bean-el:message key="ep.channels.confirm.delete" bundle="ep.messages"/>')) doAction('/ep/channelDelete.do', this.form);">
      </div>
</c:if>

        <table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="Search result table" width="100%">
          <tr class="listHeader">
            <th id="Checkboxes">&nbsp;</th>
            <th id="Name" align="left"><bean-el:message key="ep.header.name" bundle="ep.messages"/></th>
            <th id="LastModifiedDate" align="left"><bean-el:message key="ep.header.lastModifiedDate" bundle="ep.messages"/></th>
            <th id="Status" align="left"><bean-el:message key="ep.header.status" bundle="ep.messages"/></th>
            <th id="Actions" align="left" nowrap><bean-el:message key="ep.header.actions" bundle="ep.messages"/></th>
          </tr>

          <!-- results -->

<c:forEach var="breadcrumbs" items="${channels}" varStatus="index">

  <bean:size id="len" name="breadcrumbs"/>
  <c:set var="item" value="${breadcrumbs[len - 1]}"/>

          <c:url var="onlineUrl" value="/ep/myChannelsSetOnlineStatus.do">
            <c:param name="channelId" value="${item.map.id}"/>
            <c:param name="ctx.f" value="${requestScope['ctx.f']}"/>
	  </c:url>
          <c:url var="offlineUrl" value="/ep/channelSetOfflineStatus.do">
            <c:param name="channelId" value="${item.map.id}"/>
            <c:param name="ctx.f" value="${requestScope['ctx.f']}"/>
	  </c:url>
          <c:url var="editUrl" value="/ep/channelEdit.do">
            <c:param name="channelId" value="${item.map.id}"/>
            <c:param name="ctx.f" value="${requestScope['ctx.f']}"/>
	  </c:url>
          <c:url var="deleteUrl" value="/ep/channelDelete.do">
            <c:param name="channelId" value="${item.map.id}"/>
            <c:param name="ctx.f" value="${requestScope['ctx.f']}"/>
	  </c:url>

          <c:choose>
            <c:when test="${(index.count + 1) % 2 == 0}">
              <tr class="listEven">
            </c:when>
            <c:otherwise>
              <tr class="listOdd">
            </c:otherwise>
          </c:choose>
            <td headers="Checkboxes" align="center"><input type="checkbox" name="channelIds"
              onclick="update(this.form.channelIds, this.form.selectAllChannels);"
              value="<c:out value="${item.map.id}"/>"></td>

            <td headers="Name">
  <c:forEach var="crumb" items="${breadcrumbs}" varStatus="index">
          <c:url var="browseUrl" value="/ep/channelBrowse.do">
            <c:param name="channelId" value="${crumb.map.id}"/>
            <c:param name="ctx.f" value="${requestScope['ctx.f']}"/>
	  </c:url>

          / <a href="<c:out value="${browseUrl}"/>"><c:out value="${crumb.map.name}"/></a>

  </c:forEach>
            </td>

            <td headers="LastModifiedDate"><bean:write name="item" property="lastModTime" formatKey="format.datetime.short" bundle="mc.messages"/></td>

            <td headers="Status">
            <c:choose>
              <c:when test="${item.map.status == 0}">
              <bean-el:message key="ep.label.offline" bundle="ep.messages"/>
              </c:when>
	      <c:otherwise>
	      <bean-el:message key="ep.label.online" bundle="ep.messages"/>
	      </c:otherwise>
            </c:choose>
            </td>

            <td headers="Actions">
<c:if test="${item.map.editable}">
              <a href="<c:out value="${editUrl}"/>"><c:out value='${editImg}' escapeXml="false"/></a>
              <c:choose>
                <c:when test="${item.map.status == 0}">
                <a href="<c:out value="${onlineUrl}"/>"><c:out value='${onlineImg}' escapeXml="false"/></a>
                </c:when>
                <c:otherwise>
                  <a href="<c:out value="${offlineUrl}"/>"><c:out value='${offlineImg}' escapeXml="false"/></a>
                </c:otherwise>
              </c:choose>
              <a href="<c:out value="${deleteUrl}"/>" onclick="return doChannelConfirmDelete();"><c:out value='${deleteImg}' escapeXml="false"/></a>
</c:if>
            </td>

          </tr>
</c:forEach>

<c:if test="${empty channels}">
        <tr class="listOdd">
          <td align="center" colspan="5">
            <bean:message key="ep.my.channels.noFound" bundle="ep.messages"/>
          </td>
        </tr>
</c:if>

        </table>

        <!-- pagination -->
<c:if test="${not empty channels}">
<%@ include file="/mc/common/pager.jsp" %>
</c:if>

      </form>

</c:if>

    </td>
  </tr>
</table>
